<!DOCTYPE html>
<html>
	<head>
		<meta charset="UTF-8">
		<meta name="renderer" content="webkit">
		<meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1">
		<meta name="viewport" content="width=device-width,initial-scale=1,minimum-scale=1,maximum-scale=1,role-scalable=no" />
		<title>添加角色</title>
		<link rel="stylesheet" type="text/css" href="/admin/layui/css/layui.css" />
		<link rel="stylesheet" type="text/css" href="/admin/css/admin.css" />
	</head>
	<body>
		<div class="wrap-container">
			<form class="layui-form" style="width: 90%;padding-top: 20px;">
					<div class="layui-form-item">
						<label class="layui-form-label">角色ID：</label>
						<div class="layui-input-block">
							<input type="text" name="roleId" required lay-verify="required" placeholder="请输入角色ID" autocomplete="off" class="layui-input">
						</div>

					</div>
					<div class="layui-form-item">
						<label class="layui-form-label">角色名称：</label>
						<div class="layui-input-block">
							<input type="text" name="roleName" required lay-verify="required" placeholder="请输入角色名称" autocomplete="off" class="layui-input">
						</div>

					</div>
					<div class="layui-form-item">
						<label class="layui-form-label">角色描述：</label>
						<div class="layui-input-block">
							<input type="text" name="reloDesc" required lay-verify="required" placeholder="描述..." autocomplete="off" class="layui-input">
						</div>

					</div>

					<div class="layui-form-item">
						<label class="layui-form-label">角色状态：</label>
						<div class="layui-input-block">
							<input type="radio" name="roleStatus" value="0" title="正常" checked>
							<input type="radio" name="roleStatus" value="1" title="限制">
						</div>
					</div>
					<div class="layui-form-item">
						<div class="layui-input-block">
							<button class="layui-btn layui-btn-normal" lay-submit lay-filter="addUser">立即提交</button>
							<button type="reset" class="layui-btn layui-btn-primary">重置</button>
						</div>
					</div>
				</form>
		</div>

		<script src="/admin/layui/layui.js" type="text/javascript" charset="utf-8"></script>
		<script>
			//Demo
			layui.use(['form'], function() {
				var form = layui.form;
				form.render();
				$ = layui.jquery;
				//监听提交
				form.on('submit(addUser)', function(data) {
					layer.msg(JSON.stringify(data.field));
					$.ajax({
						type: "post",
						data: data.field,
						url: "http://localhost:8080/role/addRole",
						error: function (XMLHttpRequest, textStatus, errorThrown) {
							alert("系统异常，请联系管理员!");
						},
						success: function (data) {
								layer.alert(data.message, {
									skin: 'layui-layer-molv' //样式类名  自定义样式
									, closeBtn: 1    // 是否显示关闭按钮
									, anim: 1 //动画类型
									, icon: 6    // icon
								});
							refresh();
						}
				});
					return false;
				});
			});
		</script>
	</body>

</html>